********************************************************
**** Main Analysis for Schub ISQ
**** "When Prospective Leader Turnover Promotes Peace"
********************************************************

** Outline
  * I.   Manuscript Table 1
  * II.  Predicted Probabilities from Models for Manuscript Table 1 
  * III. Robustness Test Tables for Online Appendix


  
***************************
* Set working directory and load data  
clear
use "MainData_Schub_ISQ_LeaderTurnover_v2.dta"
  
  
  
***************************  
** I. Manuscript Table 1

eststo clear
qui: eststo: logit warinitstartnxtyr triturnover if war==0 & milgdpest1>10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1>10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover if war==0 & milgdpest1<=10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1<=10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover milgdpest1binary10 milgdpest1binary10triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover milgdpest1binary10 milgdpest1binary10triturnover relcap cont alliancedummy new_polity22 pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
esttab, se star(* 0.1 ** 0.05 *** 0.01) b(a2)
  
  
***************************  
** II. Predicted Probabilities from Models in Manuscript Table 1 

* Based on Model 2 (HIGH Military Spending, Moving from 0 to 2 Leader Turnovers in Prior Decade)
estsimp logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1>10, cl(dyadid)
setx median
setx triturnover 0 
simqi, listx prval(1) 
setx triturnover 2 
simqi, listx prval(1)
setx triturnover 0 
simqi, listx fd(pr) changex(triturnover 0 2) 
 
* Based on Model 4 (LOW Military Spending, Moving from 0 to 2 Leader Turnovers in Prior Decade)
drop b1 b2 b3 b4 b5 b6 b7 b8
estsimp logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1<=10, cl(dyadid)
setx median
setx triturnover 0 
simqi, listx prval(1)
setx triturnover 2
simqi, listx prval(1)
setx triturnover 0 
simqi, listx fd(pr) changex(triturnover 0 2) 

* For Manuscript Figure 3 based on Model 6 **
  ** high spending
drop b1 b2 b3 b4 b5 b6 b7 b8 
estsimp logit warinitstartnxtyr triturnover milgdpest1binary10 milgdpest1binary10triturnover relcap cont alliancedummy new_polity22 pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
setx median
setx triturnover 0 milgdpest1binary10 1 milgdpest1binary10triturnover 0
simqi, listx prval(1)
setx triturnover 2 milgdpest1binary10 1 milgdpest1binary10triturnover 2
simqi, listx prval(1)
setx triturnover 0 milgdpest1binary10 1 milgdpest1binary10triturnover 0
simqi, listx fd(pr) changex(triturnover 0 2 milgdpest1binary10 1 1 milgdpest1binary10triturnover 0 2) 
  *1.6%-->0.2%: fd of -1.434% [,-3.045,-0.450] *outputs used for Figure 3--see "Schub_ISQ_LeaderTurnover_Figures.R"* 
  ** low spending 
setx median 
setx triturnover 0 milgdpest1binary10 0 milgdpest1binary10triturnover 0 
simqi, listx prval(1)
setx triturnover 2 milgdpest1binary10 0 milgdpest1binary10triturnover 0 
simqi, listx prval(1)
setx triturnover 0 milgdpest1binary10 0 milgdpest1binary10triturnover 0 
simqi, listx fd(pr) changex(triturnover 0 2 milgdpest1binary10 0 0 milgdpest1binary10triturnover 0 0) 
  *0.5%-->0.3%: fd of -0.204% [-0.549,0.248] *outputs used for Figure 3--see "Schub_ISQ_LeaderTurnover_Figures.R"* 

  
  
  
***************************  
** III. Robustness Test Tables for Online Appendix 

* Table A1: Summary Statistics
summ warinitstartnxtyr triturnover sol2y10 binaryturnover milgdpest1binary10 relcap cont alliancedummy new_polity22 pceyrs if war==0 & warinitstartnxtyr!=.


* Table A2: Continuous Turnover Variable 
gen milgdpest1binary10contturnover=milgdpest1binary10*sol2y10
 
eststo clear
qui: eststo: logit warinitstartnxtyr sol2y10 if war==0 & milgdpest1>10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr sol2y10 relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1>10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr sol2y10 if war==0 & milgdpest1<=10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr sol2y10 relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1<=10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr sol2y10 milgdpest1binary10 milgdpest1binary10contturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
qui: eststo: logit warinitstartnxtyr sol2y10 milgdpest1binary10 milgdpest1binary10contturnover relcap cont alliancedummy new_polity22 pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
esttab, se star(* 0.1 ** 0.05 *** 0.01) 


* Table A3: Binary Turnover Variable
gen milgdpest1binary10binaryturnover=milgdpest1binary10*binaryturnover

eststo clear
qui: eststo: logit warinitstartnxtyr binaryturnover if war==0 & milgdpest1>10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr binaryturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1>10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr binaryturnover if war==0 & milgdpest1<=10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr binaryturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1<=10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr binaryturnover milgdpest1binary10 milgdpest1binary10binaryturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
qui: eststo: logit warinitstartnxtyr binaryturnover milgdpest1binary10 milgdpest1binary10binaryturnover relcap cont alliancedummy new_polity22 pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
esttab, se star(* 0.1 ** 0.05 *** 0.01) 

  ** Figure A3 Inputs: based on Table A3 Model 6 **
  ** high spending
drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11
estsimp logit warinitstartnxtyr binaryturnover milgdpest1binary10 milgdpest1binary10binaryturnover relcap cont alliancedummy new_polity22 pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
setx median
setx binaryturnover 0 milgdpest1binary10 1 milgdpest1binary10binaryturnover 0
simqi, listx prval(1)
setx binaryturnover 1 milgdpest1binary10 1 milgdpest1binary10binaryturnover 1
simqi, listx prval(1)
setx binaryturnover 0 milgdpest1binary10 1 milgdpest1binary10binaryturnover 0
simqi, listx fd(pr) changex(binaryturnover 0 1 milgdpest1binary10 1 1 milgdpest1binary10binaryturnover 0 1) 
  ** low spending 
setx median 
setx binaryturnover 0 milgdpest1binary10 0 milgdpest1binary10binaryturnover 0 
simqi, listx prval(1)
setx binaryturnover 1 milgdpest1binary10 0 milgdpest1binary10binaryturnover 0 
simqi, listx prval(1)
setx binaryturnover 0 milgdpest1binary10 0 milgdpest1binary10binaryturnover 0 
simqi, listx fd(pr) changex(binaryturnover 0 1 milgdpest1binary10 0 0 milgdpest1binary10binaryturnover 0 0) 
 * see "Schub_ISQ_LeaderTurnover_Figures.R" for code generating the figure *

 

* Table A4: Varying Cut Points
 *i: high spending
eststo clear
qui: eststo: logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1>8, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1>9, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1>10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1>11, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1>12, cl(dyadid)
esttab, se star(* 0.1 ** 0.05 *** 0.01)  

 *ii: lowspending
eststo clear
qui: eststo: logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1<=8, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1<=9, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1<=10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1<=11, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1<=12, cl(dyadid)
esttab, se star(* 0.1 ** 0.05 *** 0.01) 


* Table A5: OLS Specification
eststo clear
qui: eststo: reg warinitstartnxtyr triturnover if war==0 & milgdpest1>10, cl(dyadid)
qui: eststo: reg warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1>10, cl(dyadid)
qui: eststo: reg warinitstartnxtyr triturnover if war==0 & milgdpest1<=10, cl(dyadid)
qui: eststo: reg warinitstartnxtyr triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1<=10, cl(dyadid)
qui: eststo: reg warinitstartnxtyr triturnover milgdpest1binary10 milgdpest1binary10triturnover relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
qui: eststo: reg warinitstartnxtyr triturnover milgdpest1binary10 milgdpest1binary10triturnover relcap cont alliancedummy new_polity22 pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
esttab, se star(* 0.1 ** 0.05 *** 0.01) 



* Table A6 and Figure A4: Penalized Logit *see "Schub_ISQ_LeaderTurnover_Figures.R"



* Table A7: Additional Controls 
eststo clear
qui: eststo: logit warinitstartnxtyr triturnover if war==0 & milgdpest1>10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover rivals relcap cont alliancedummy new_polity22 pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1>10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover if war==0 & milgdpest1<=10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover rivals relcap cont alliancedummy new_polity22 pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1<=10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover milgdpest1binary10 milgdpest1binary10triturnover rivals relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover milgdpest1binary10 milgdpest1binary10triturnover rivals relcap cont alliancedummy new_polity22 pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
esttab, se star(* 0.1 ** 0.05 *** 0.01) 



* Table A8: Fewer Controls
eststo clear
qui: eststo: logit warinitstartnxtyr triturnover relcap pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1>10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1>10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover relcap pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1<=10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & milgdpest1<=10, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover milgdpest1binary10 milgdpest1binary10triturnover relcap new_polity22 pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
qui: eststo: logit warinitstartnxtyr triturnover milgdpest1binary10 milgdpest1binary10triturnover cont alliancedummy new_polity22 pceyrs pceyrs2 pceyrs3 if war==0, cl(dyadid)
esttab, se star(* 0.1 ** 0.05 *** 0.01)  



* Table A9: Undirected War Onset
gen attack2condition=0 
replace attack2condition=1 if milgdpest1>=10 & sol2y10==0
* 1 when ccode1 has high military spending and ccode2 has no leader coalition turnover

gen attack1condition=0
replace attack1condition=1 if milgdpest2>=10 & sol1y10==0
* 1 when ccode2 has high military spending and ccode1 has no leader coalition turnover

gen attackcondition=0
replace attackcondition=1 if (attack2condition + attack1condition) > 0
* 1 when either country is locked in a costly peace with an entrenched leader

eststo clear
qui: eststo: logit waronsetnxtyr attackcondition if war==0 & ccode1<ccode2, cl(dyadid2)
qui: eststo: logit waronsetnxtyr attackcondition relcap cont alliancedummy pceyrs pceyrs2 pceyrs3 if war==0 & ccode1<ccode2, cl(dyadid2)
esttab, se star(* 0.1 ** 0.05 *** 0.01)
* limit sample to dyads going in only one direction to avoid double counting



* Figure A5 Inputs: Democratic and Non-Democratic Targets separated (see "Schub_ISQ_LeaderTurnover_Figures.R" for Figures)
 * HIGH military spending  
   *Dem  
mean warinitstartnxtyr if triturnover==0 & milgdpest1binary10==1 & war==0 & targdem==1
mean warinitstartnxtyr if triturnover==1 & milgdpest1binary10==1 & war==0 & targdem==1  
mean warinitstartnxtyr if triturnover==2 & milgdpest1binary10==1 & war==0 & targdem==1  
   *Non-Dem  
mean warinitstartnxtyr if triturnover==0 & milgdpest1binary10==1 & war==0 & targdem==0
mean warinitstartnxtyr if triturnover==1 & milgdpest1binary10==1 & war==0 & targdem==0  
mean warinitstartnxtyr if triturnover==2 & milgdpest1binary10==1 & war==0 & targdem==0      
*DEM: 4.3 (69); 5.3 (57); 0 (61)
*NON: 2.0 (304); 0 (97); 0 (66)  
 
 * LOW military spending
    *Dem  
mean warinitstartnxtyr if triturnover==0 & milgdpest1binary10==0 & war==0 & targdem==1
mean warinitstartnxtyr if triturnover==1 & milgdpest1binary10==0 & war==0 & targdem==1  
mean warinitstartnxtyr if triturnover==2 & milgdpest1binary10==0 & war==0 & targdem==1  
    *Non-Dem  
mean warinitstartnxtyr if triturnover==0 & milgdpest1binary10==0 & war==0 & targdem==0
mean warinitstartnxtyr if triturnover==1 & milgdpest1binary10==0 & war==0 & targdem==0  
mean warinitstartnxtyr if triturnover==2 & milgdpest1binary10==0 & war==0 & targdem==0     
*DEM: 2.8 (424); 0 (304); 0.8 (527)
*NON: 0.5 (2339); 0.8 (743); 0.4 (769) 







